/**
 * 角色管理新增页面JS
 * User: zhaoming
 * Date: 15-8-17
 * Time: 下午5:58
 * To change this template use File | Settings | File Templates.
 */
$(function(){
    //激活左侧导航菜单
    activeNavBar("MANAGE_ROLE_INFO");
    initSelect2();
    $("#saveBtn").click(function(){
        save();
    });
    $("#goBackBtn, #headGoBackBtn").click(function(){
        window.forward(springUrl+ "/web/roleInfo/index");
    });
});

/**
 * 保存
 */
function save(){
    if($('#addForm').trigger("validate").isValid()){
        var index =  layer.msg('正在处理中...', {icon: 16, shade: 0.3, time: 0});
        jQuery.ajax({
            type: "POST",
            dataType: "json",
            url: springUrl + "/web/roleInfo/insert",
            data: {
                roleCode: $('#roleCode').val(),
                roleName : $('#roleName').val(),
                roleTypeCode : $('#roleTypeCode').val(),
                roleTypeName : $('#roleTypeCode').val()!="" ? $('#roleTypeCode option:selected').text() : "",
                remark : $('#remark').val()
            },
            success: function (data) {
                layer.close(index);
                Alert.success("数据保存成功!", function(){
                    window.forward(springUrl+ "/web/roleInfo/index");
                });
            },
            error: function(data){
                layer.close(index)
                Alert.error(data.responseText);
            }
        });
    }
}

